
const Koa = require('koa');
const static_ = require('koa-static')
const path = require('path')
const fs = require('fs')

const app = new Koa();
const port = 2333;
const dirPath = '/dist/' 

app.use(async (ctx, next) => { 
    await next() 
    if (ctx.response.status === 404) { 
      ctx.type = 'text/html; charset=utf-8' 
      ctx.body= fs.readFileSync(`.${  dirPath  }index.html`) 
    }
})

app.use(static_(
    path.join(__dirname, './dist/')
))
app.listen(port);

console.log('oJBk',`serve at localhost:${port}`)

